module HashModel
  
  class Model
    
    def initialize(hash)
      if /^Hash/.match(hash.class.to_s)
        @my_hash = hash 
      else
        raise "Only a hash may be passed to object.  You passed: #{hash.class.to_s}"
      end
    end    
    
    def empty?
      @my_hash.empty?
    end
  
  	def method_missing(method_id)
      
      # if value is an number, then we should return an int.  This is for the select helper.  "1" and 1 are not the same, so the selected element does not get chosen.
  	  if @my_hash && @my_hash.key?(method_id.to_s) && /\A\d+\Z/.match(@my_hash[method_id.to_s])
  	    @my_hash[method_id.to_s].to_i  	  
  	  elsif @my_hash && @my_hash.key?(method_id.to_s)
  	    @my_hash[method_id.to_s]
  	  else 
  	    nil
  	  end
  	end
  end
end